con = ['ABCDEF', 'BACDE', 'CABE', 'DABE', 'EABCD', 'FA']


def map_reducer(a=[]):
    dir = {}
    for line in con:
        for i in range(1, len(line) - 1):
            for j in range(i + 1, len(line)):
                strr = line[i] + line[j]
                if strr in dir:
                    dir[strr] += line[0]
                else:
                    dir[strr] = line[0]
    for i in dir:
        print(i, '的共同朋友为：', dir[i])


if __name__ == '__main__':
    map_reducer(con)
